package JavaSE.Class10.Animal;

//多态
//不同对象调用同种方法得到不同的结果就是多态
public class Main {
    public void eat(Animal animal){
        animal.eat();
    }

    public static void main(String[] args) {
        Animal animal = new Bird("小鸟",2);
        Bird bird = (Bird)animal;//要强转才能用
        bird.fly();
        Animal animal2=new Dog("旺财",18);
//        Dog dog=(Bird)animal2;
//        dog.fly();
        //错的
    }

    public static void main1() {
        Animal d=new Dog("旺财",1);
        d.eat();
        Dog dog=new Dog("小黑",5);
        dog.eat();
        Bird b=new Bird("鸟鸟",2);
        b.eat();
    }
}
